package com.jk.controller;

import com.jk.bean.Daohang;
import com.jk.bean.GongGao;
import com.jk.service.DaoHangService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Description: 骚骚的🐏
 * @Author: 杨
 * @Date: 2019/3/5 19:54
 */
@Controller
@RequestMapping("daohang")
public class DaoHangController {
    @Autowired
    private DaoHangService daoHangService;
   @ResponseBody
   @RequestMapping("querydaohang")
   public List<Daohang> querydaohang(){
      List<Daohang> list=daoHangService.querydaohang();

       return  list;
   }
   //查询公告
   @ResponseBody
   @RequestMapping("queryGongGao")
   public List<GongGao> queryGongGao(){
      List<GongGao> list=daoHangService.queryGongGao();

       return  list;
   }
    //查询重大公告
   @ResponseBody
   @RequestMapping("queryGongGaoZhong")
   public List<GongGao> queryGongGaoZhong(){
      List<GongGao> list=daoHangService.queryGongGaoZhong();

       return  list;
   }
   //不再提示
    @ResponseBody
   @RequestMapping("gonggaostatus")
   public String gonggaostatus(HttpServletRequest request, HttpServletResponse response){
        Cookie cookie = new Cookie("gonggao","1");
        cookie.setMaxAge(604800);
        //当前应用任何目录下都能访问cookie
        cookie.setPath("/");
        response.addCookie(cookie);
        //此时cookie还在服务器上  要把cookie发送到浏览器上  通过相应对象
        return  null;
   }



    @Autowired
    @ResponseBody
    @RequestMapping("upfile")
    public List<Daohang> upfile(){
        List<Daohang> list=daoHangService.querydaohang();

        return  list;
    }
}
